﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DAL;

public partial class Page_ContactUs : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Submit_Click(object sender, EventArgs e)
    {
        bool is_HaveError = false;
        if ((FullName.Text == null) || (FullName.Text == ""))
        {
            Error_FullName.Text = "error";
            is_HaveError = true;
        }
        if ((Phone.Text == null) || (Phone.Text == ""))
        {
            Error_Phone.Text = "error";
            is_HaveError = true;
        }
        if ((Email.Text == null) || (Email.Text == ""))
        {
            Error_Email.Text = "error";
            is_HaveError = true;
        }
        if ((Subject.Text == null) || (Subject.Text == ""))
        {
            Error_Subject.Text = "error";
            is_HaveError = true;
        }
        if ((Content.Text == null) || (Content.Text == ""))
        {
            Error_Content.Text = "error";
            is_HaveError = true;
        }
        if (is_HaveError)
            return;

        ContactBLL.SaveContact(FullName.Text.Trim(), Phone.Text.Trim(), Email.Text.Trim(), Subject.Text.Trim(), Content.Text.Trim());

        // Add alert
        // System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=\"JavaScript\">alert(\"Hello this is an Alert\")</SCRIPT>");
        ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Thank you for your information. We will contact with you soon." + "');", true);

        FullName.Text = "";
        Phone.Text = "";
        Email.Text = "";
        Subject.Text = "";
        Content.Text = "";

        Error_FullName.Text = "";
        Error_Phone.Text = "";
        Error_Email.Text = "";
        Error_Subject.Text = "";
        Error_Content.Text = "";
    }
    protected void Reset_Click(object sender, EventArgs e)
    {
        FullName.Text = "";
        Phone.Text = "";
        Email.Text = "";
        Subject.Text = "";
        Content.Text = "";

        Error_FullName.Text = "";
        Error_Phone.Text = "";
        Error_Email.Text = "";
        Error_Subject.Text = "";
        Error_Content.Text = "";
    }
}
